package cn.idu.ismik.sample.reflection;

/**
 * 测试类什么时候初始化
 */
public class Test06 {
    static {
        System.out.println("main类被加载");
    }

    public static void main(String[] args) throws ClassNotFoundException {
        //1. 主动引用
//        S s = new S();

        //2. 反射
//        Class.forName("cn.idu.ismik.sample.reflection.S");

        System.out.println(S.L);
    }
}

class F {
    static {
        System.out.println("父类被加载");
    }

    static int L = 0;
}

class S extends F {
    static {
        System.out.println("子类被加载");
        m = 300;
    }

    static int m = 100;

    static final int M = 1;
}
